<?php
namespace script\demo2;

class InsertOrder
{
    /**
     * 模拟定时下单,每次运行创建20个订单..
     */
    public function run()
    {
        //读取config/database/shr.php的配置文件,初始化数据库,获取连接句柄
        $db = \lib\DB::instance('shr');
        $time = time();

        $i = 20;
        while ($i) {
            $i--;
            $orderData = ['order_sn' => uniqid(),'pay_status'=>rand(0,1), 'add_time' => $time];
            //插入订单数据
            $db->table('order')->insert($orderData);
        }
    }

}